
import java.io.*;

public class UtilsArquivo {

    public static void salvar(String arquivo, String conteudo, boolean adicionar)
            throws IOException {

        FileWriter fw = new FileWriter(arquivo, adicionar);
        fw.write(conteudo);
        fw.close();
    }

    public static String carregar(String arquivo)
            throws FileNotFoundException, IOException {

        File file = new File(arquivo);

        if (!file.exists()) {
            return null;
        }

        BufferedReader br = new BufferedReader(new FileReader(arquivo));
        StringBuilder bufSaida = new StringBuilder();

        String linha;
        while ((linha = br.readLine()) != null) {
            bufSaida.append(linha).append("\n");

        }
        br.close();
        return bufSaida.toString();
    }
}
